package com.cat.slidingWindow;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/two-sum-ii-input-array-is-sorted/
 * @create 2025/9/17 22:01
 * @since JDK17
 */

public class Solution43 {
    public int[] twoSum(int[] numbers, int target) {
        for (int l = 0, r = numbers.length - 1; l < r; ) {
            if (numbers[l] + numbers[r] > target) {
                r--;
            } else if (numbers[l] + numbers[r] < target) {
                l++;
            } else {
                return new int[]{l + 1, r + 1};
            }
        }
        return new int[2];
    }
}
